<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>用户审核</title>

  {include file='common/_require'/}
</head>

<body>

  {include file='common/_header'/}

  <div class="layui-container fly-marginTop fly-user-main">
    {include file='common/_user'/}
    <script>$('.user-nav-item-auth').addClass('layui-this')</script>


    <div class="fly-panel fly-panel-user" pad20>
      <div class="layui-tab layui-tab-brief" lay-filter="user">
        <ul class="layui-tab-title auth-status">
          <li class="auth-status-3" data-href="{:url('authManage',['auth_status'=>3])}">待审核</li>
          <li class="auth-status-1" data-href="{:url('authManage',['auth_status'=>1])}">已认证</li>
          <li class="auth-status-2" data-href="{:url('authManage',['auth_status'=>2])}">已撤回</li>
          <li class="auth-status-4" data-href="{:url('authManage',['auth_status'=>4])}">已驳回</li>
        </ul>
        <script>$('.auth-status-{$Request.param.auth_status|default="3"}').addClass('layui-this')</script>
        <div class="layui-tab-content" style="padding: 20px 0;">
          <div class="layui-form layui-form-pane layui-tab-item layui-show">

            <table class="layui-table">
              <thead>
                <tr>
                  <th>用户ID</th>
                  <th>用户昵称</th>
                  <th>认证信息</th>
                  <th>认证状态</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>
                {volist name='list_user' id='auth_user'}

                <tr class="item" data-id="{$auth_user.id}">
                  <td>{$auth_user.id}</td>
                  <td>{$auth_user.nickname}</td>
                  <td>{:\\app\\common\\TextFormat::br($auth_user.auth_content)}</td>
                  <td>{$auth_user.auth_status_name}</td>
                  <td>
                    <div>
                      {in name='Request.param.auth_status|default="3"' value='2,3,4' }
                      <div class="layui-btn layui-btn-sm pass">通过</div>
                      {/in}
                      {in name='Request.param.auth_status|default="3"' value='3' }
                      <div class="layui-btn layui-btn-sm refuse">驳回</div>
                      {/in}
                      {in name='Request.param.auth_status|default="3"' value='1' }
                      <div class="layui-btn layui-btn-sm refund">撤回</div>
                      {/in}
                    </div>
                  </td>
                </tr>
                {/volist}
                {empty name='$list_user'}
                <tr>
                  <td colspan="6">暂无数据</td>
                </tr>
                {/empty}
              </tbody>
            </table>

          </div>

        </div>

      </div>
    </div>
  </div>
  </div>
  {include file='common/_footer'/}

  <script>

    layui.use(['form', 'upload'], function () {

      $('.auth-status li').click(function () {
        var item = this;

        var data = $(item).data();

        location.href = data.href
      })

      $('.pass').click(function () {
        var item = this;
        layer.prompt({
          title: '向用户发送消息',
          formType: 2,
          value: '恭喜您,您的认证信息已通过'
        }, function (value, index) {

          $.post('{:url("updateAuthStatus")}', {
            id: $(item).parents('.item').data('id'),
            auth_status: 1,
            message: value
          }, function (result) {
            if (result.code == 0) {
              layer.msg('设置成功')
              layer.close(index)
              setTimeout(() => {
                location.reload();
              }, 1200);
            } else {
              layer.msg(result.msg)
            }
          })
        })
      })
      $('.refund').click(function () {
        var item = this;
        layer.prompt({
          title: '向用户发送消息',
          formType: 2,
          value: '对不起,您的认证信息已撤回,有问题请回复消息'
        }, function (value, index) {

          $.post('{:url("updateAuthStatus")}', {
            id: $(item).parents('.item').data('id'),
            auth_status: 2,
            message: value
          }, function (result) {
            if (result.code == 0) {
              layer.msg('设置成功')
              layer.close(index)
              setTimeout(() => {
                location.reload();
              }, 1200);
            } else {
              layer.msg(result.msg)
            }
          })
        })
      })
      $('.refuse').click(function () {
        var item = this;
        layer.prompt({
          title: '向用户发送消息',
          formType: 2,
          value: '对不起,您的认证信息已驳回,有问题请回复消息'
        }, function (value, index) {

          $.post('{:url("updateAuthStatus")}', {
            id: $(item).parents('.item').data('id'),
            auth_status: 4,
            message: value
          }, function (result) {
            if (result.code == 0) {
              layer.msg('设置成功')
              layer.close(index)
              setTimeout(() => {
                location.reload();
              }, 1200);
            } else {
              layer.msg(result.msg)
            }
          })
        })
      })
    })

  </script>
</body>

</html>